import { IPSModelSortable } from '../../ipsmodel-sortable';
import { IPSSystem } from '../../ipssystem';
import { IPSDataEntity } from '../ipsdata-entity';
import { IPSDEDataSet } from '../ds/ipsdedata-set';
import { IPSDEUserRole } from './ipsdeuser-role';
import { IPSDEUserRoleOPPriv } from './ipsdeuser-role-oppriv';
import { IPSSysUserDR } from '../../security/ipssys-user-dr';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEUserRoleImpl extends PSModelObjectImpl implements IPSDEUserRole, IPSModelSortable {
  get codeName(): string {
    return this.M.codeName;
  }

  get customCond(): string {
    return this.M.customCond;
  }

  get customDRMode(): string {
    return this.M.customDRMode;
  }

  get customDRMode2(): string {
    return this.M.customDRMode2;
  }

  get customDRMode2Param(): string {
    return this.M.customDRMode2Param;
  }

  get customDRModeParam(): string {
    return this.M.customDRModeParam;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get extendMode(): 0 | 2 {
    return this.M.extendMode != null ? this.M.extendMode : 0;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  get orderValue(): number {
    return this.M.orderValue != null ? this.M.orderValue : 99999;
  }

  get orgDR(): 1 | 2 | 4 | 8 {
    return this.M.orgDR != null ? this.M.orgDR : 0;
  }

  protected psdedataset: IPSDEDataSet | null = null;

  getPSDEDataSet(): IPSDEDataSet | null {
    if (this.psdedataset != null) return this.psdedataset;
    const value = this.M.getPSDEDataSet;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.psdedataset = ipsdataentity.findPSDEDataSet(value);
    }
    return this.psdedataset;
  }

  get psDEDataSet(): IPSDEDataSet | null {
    return this.getPSDEDataSet();
  }

  getPSDEDataSetMust(): IPSDEDataSet {
    const value = this.getPSDEDataSet();
    if (value == null) {
      throw new Error('未指定实体数据集');
    }
    return value;
  }

  protected psdeuserroleopprivs: IPSDEUserRoleOPPriv[] | null = null;

  getPSDEUserRoleOPPrivs(): IPSDEUserRoleOPPriv[] | null {
    if (this.psdeuserroleopprivs == null) {
      this.psdeuserroleopprivs = this.fillChildListModel(this.M.getPSDEUserRoleOPPrivs, 'dataentity.priv.IPSDEUserRoleOPPriv') as IPSDEUserRoleOPPriv[];
    }
    return this.psdeuserroleopprivs;
  }

  get psDEUserRoleOPPrivs(): IPSDEUserRoleOPPriv[] | null {
    return this.getPSDEUserRoleOPPrivs();
  }

  findPSDEUserRoleOPPriv(objKey: any): IPSDEUserRoleOPPriv | null {
    return this.getPSModel5('dataentity.priv.IPSDEUserRoleOPPriv', this.getPSDEUserRoleOPPrivs(), objKey) as IPSDEUserRoleOPPriv;
  }

  protected pssysuserdr: IPSSysUserDR | null = null;

  getPSSysUserDR(): IPSSysUserDR | null {
    if (this.pssysuserdr != null) return this.pssysuserdr;
    const value = this.M.getPSSysUserDR;
    if (value == null) {
      return null;
    }
    const ipssystem = this.getParentPSModelObject('IPSSystem') as IPSSystem;
    if (ipssystem != null) {
      this.pssysuserdr = ipssystem.findPSSysUserDR(value);
    }
    return this.pssysuserdr;
  }

  get psSysUserDR(): IPSSysUserDR | null {
    return this.getPSSysUserDR();
  }

  getPSSysUserDRMust(): IPSSysUserDR {
    const value = this.getPSSysUserDR();
    if (value == null) {
      throw new Error('未指定用户数据范围对象');
    }
    return value;
  }

  protected pssysuserdr2: IPSSysUserDR | null = null;

  getPSSysUserDR2(): IPSSysUserDR | null {
    if (this.pssysuserdr2 != null) return this.pssysuserdr2;
    const value = this.M.getPSSysUserDR2;
    if (value == null) {
      return null;
    }
    const ipssystem = this.getParentPSModelObject('IPSSystem') as IPSSystem;
    if (ipssystem != null) {
      this.pssysuserdr2 = ipssystem.findPSSysUserDR(value);
    }
    return this.pssysuserdr2;
  }

  get psSysUserDR2(): IPSSysUserDR | null {
    return this.getPSSysUserDR2();
  }

  getPSSysUserDR2Must(): IPSSysUserDR {
    const value = this.getPSSysUserDR2();
    if (value == null) {
      throw new Error('未指定用户数据范围对象2');
    }
    return value;
  }

  get roleTag(): string {
    return this.M.roleTag;
  }

  get secBC(): string {
    return this.M.secBC;
  }

  get secDR(): 1 | 2 | 4 | 8 {
    return this.M.secDR != null ? this.M.secDR : 0;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userDRAction(): string {
    return this.M.userDRAction;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get allData(): boolean {
    return this.M.allData != null ? this.M.allData : false;
  }

  get defaultMode(): boolean {
    return this.M.defaultMode != null ? this.M.defaultMode : false;
  }

  get enableOrgDR(): boolean {
    return this.M.enableOrgDR != null ? this.M.enableOrgDR : false;
  }

  get enableSecBC(): boolean {
    return this.M.enableSecBC != null ? this.M.enableSecBC : false;
  }

  get enableSecDR(): boolean {
    return this.M.enableSecDR != null ? this.M.enableSecDR : false;
  }

  get enableUserDR(): boolean {
    return this.M.enableUserDR != null ? this.M.enableUserDR : false;
  }

  get systemReserved(): boolean {
    return this.M.systemReserved != null ? this.M.systemReserved : false;
  }

  get cls(): string {
    return 'PSDEUserRoleImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'IPSModelSortable' || cls == 'dataentity.priv.IPSDEUserRole') return true;
    return super.instanceof(cls);
  }
}
